<template>
	<view class="container">
		<view class="wrapper">
			<view class="main" >
				<scroll-view class="scroll" :scroll-y="true" :scroll-top="scrollTop" :show-scrollbar="false"
					:refresher-threshold="50" :refresher-triggered="refreshStatus" :lower-threshold="100"
					:scroll-with-animation="true" refresher-enabled="true" @refresherrefresh="onRefreshData"
					@scrolltolower="onLoadData" @scroll="onScroll">
					
					
					<view class="column">
						<view style="margin-bottom: 20rpx;background-color: #ffffff;" v-for="item in list" :key="item.id">
							<view class="item">
								{{ item }}
							</view>
							
							<view style="border-top: 1px solid #e5e5e5;padding: 20rpx 10rpx 20rpx 10rpx;">
								<u-grid :border="true" :col="2">
									<u-grid-item >
										<text style="font-size: 31rpx;" @click="delCourse(item.id)">删除</text>
									</u-grid-item >
									<u-grid-item >
										<text style="font-size: 31rpx;" @click="editCourse(item.id)">编辑</text>
									</u-grid-item >
								</u-grid>
							</view>
						</view>
						
						
					</view>
					
					<view class="nullData" v-if="page == 1 && list.length <=0">
						<view>
							<view>
								<image src="../../../static/image/notdata.png" class="nullImage"></image>
							</view>
							<view class="nullText">
								暂无记录
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				//当前页数
				page: 1,
				//每页显示条数
				size: 10,
				//列表数据
				list: [],
				//总页数
				pages: 0,
				//监听滚动
				scrollTop: 0,
				realScrollTop: 0,
				refreshStatus: false,
				//身份（1：普通用户，2：场馆主，3：教练员，4：指导员，5：体检中心）
				identity: '',
				//指导员或者教练的ID
				userId: ''
			}
		},
		onLoad() {
			
		},
		onShow() {
			this.userId = uni.getStorageSync('userId');
			this.identity = uni.getStorageSync('identity');
			this.fetchList();
		},
		methods: {
			// 获取评论记录
			fetchList() {
				uni.showLoading({
					title: "加载中",
					mask: true
				})
				var params = {};
				params.current = this.page;
				params.size = this.size;
				params.bladeUserId = uni.getStorageSync('userId');
				this.$request({
					url: '/blade-merchant-app/merchant-app/orderEvaluate/user-evaluate',
					data: params
				}).then(res => {
					const {
						records = [],
							pages
					} = res.data;
					
					if (this.page === 1) {
						this.list = records;
					} else {
						this.list = this.list.concat(records);
					}
					this.pages = pages || 0;
					setTimeout(() => {
						this.refreshStatus = false;
						uni.hideLoading();
					}, 300);
				})
			},
			// 监听滚动事件
			onScroll(e) {
				this.realScrollTop = e.detail.scrollTop;
			},
			// 刷新数据
			onRefreshData() {
				this.refreshStatus = true;
				this.page = 1;
				this.list = [];
				this.fetchList();
			},
			// 加载数据
			onLoadData() {
				if (this.page < this.pages) {
					this.page += 1;
					this.fetchList();
				}
			},
			onLink(path) {
				uni.navigateTo({
					url: path
				})
			},
		}
	}
</script>


<style lang="scss">
	page {
		height: 100%;
		overflow: hidden;
		background: #f1f1f1;

		.container {
			height: 100%;

			.wrapper {
				display: flex;
				flex-direction: column;
				height: calc(100% - 70px);

				.header {
					display: flex;
					flex-direction: row;
					padding: 52rpx 0;
					color: #fff;
					background-color: #22A5FF;
					z-index: 1;

					.subsection {
						background: #ffffff; padding: 10rpx 10rpx;
					}
				}

				.main {
					flex: 1;
					height: 100%;

					.scroll {
						height: 100%;

							.column {
								padding: 0rpx;
								
							 
							}
					}
				}
			}
		}
		
		.nullData {
			height: 100%;
			display: flex;
			-webkit-box-pack: center;
			justify-content: center;
			-webkit-box-align: center;
			align-items: center;
			
			.nullImage {
				width: 120px;height: 120px;
			}
			.nullText {
				color:#666666;font-size:29rpx;padding-top:15rpx;text-align: center;
			}
			
		}
	}
	
</style>
